class Solution:
    def generate(self, numRows):
        triangle = []
        for i in range(numRows):
            row = [1] * (i+1)
            for j in range(1,len(row)-1): # 可以替换成for j in range(1,i)
                row[j] = triangle[i-1][j-1] + triangle[i-1][j]
            triangle.append(row)
        return triangle
if __name__ == '__main__':
    s = Solution()
    print(s.generate(5))